﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class AlertBubble : MonoBehaviour
{

    private static AlertBubble m_instance;
    public static void Show(string content)
    {
        m_instance.DoShow(content);
    }

    public GameObject template;

    private void DoShow(string content)
    {
        var go = GameObject.Instantiate(template, template.transform.parent);
        var label = go.transform.Find("text").GetComponent<Text>();
        label.text = content;
        StartCoroutine(StartAnim(go));

    }

    private IEnumerator StartAnim(GameObject go)
    {
        go.SetActive(true);
        go.transform.DOLocalMoveY(go.transform.localPosition.y + 100, 0.5f);
        yield return new WaitForSeconds(1.2f);
        Destroy(go);
        yield break;
    }

    private void Awake()
    {
        m_instance = this;
    }

   

}
